<template>
  <div>
    <el-table :data="tableData" style="width: 100%;">
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left" inline class="demo-table-expand">
            <el-table :data="props.row.staffList" style="width: 100%;"  :header-cell-style="{background:'#eeeeee'}" :cell-style="{background:'#eeeeee'}">
              <el-table-column label="员工ID" prop="id" width="80"></el-table-column>
              <el-table-column label="账号" prop="account" width="100"></el-table-column>
              <el-table-column label="密码" prop="passWord" width="80"></el-table-column>
              <el-table-column label="昵称" prop="nickName" width="80"></el-table-column>
              <el-table-column label="类型" prop="type" width="150"></el-table-column>
              <el-table-column label="操作" width="250">
                <template slot-scope="scope">
                  <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                  <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-form>
        </template>
      </el-table-column>
      <el-table-column label="部门ID"  width="150" prop="id"></el-table-column>
      <el-table-column label="部门名称"  width="350" prop="name"></el-table-column>

      <el-table-column  label="操作" width="200">
        <template slot-scope="scope">
          <el-button size="mini" type="primary" @click="handleEdit1(scope.$index, scope.row)">删除部门</el-button>
          <el-button size="mini" type="danger" @click="handleDelete1(scope.$index, scope.row)">修改部门</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination :current-page="pageInfo.currentPage" :page-size="pageInfo.pageSize"
                   :page-sizes="[3, 5, 8, 20]" :total="pageInfo.total" layout="total, sizes, prev, pager, next, jumper"
                   @size-change="handleSizeChange" @current-change="handleCurrentChange">
    </el-pagination>
  </div>
</template>

<script>
export default {

  data() {
    return {
      tableData: [],
      pageInfo: {
        total: 10,
        currentPage: 4,
        pageNum: 1,
        pageSize: 8
      }

    }
  },
  mounted() {
    this.findList(1, this.pageInfo.pageSize);
  },
  methods: {
    goto() {

    },
    handleDelete(index, row) {
      alert("删除按钮-" + index + "-" + row.id);
    },
    handleEdit(index, row) {
      alert("修改按钮-" + index + "-" + row.id);
    },
    handleDelete1(index, row) {
      alert("删除部门按钮-" + index + "-" + row.id);
    },
    handleEdit1(index, row) {
      alert("修改部门按钮-" + index + "-" + row.id);
    },
    formatDate(row, column, cellValue) {
      let date = new Date(cellValue);
      return date.toLocaleString();
    },
    findList(page, limit) {
      var that = this;
      this.$http.post("/getAllDept/" + page + "/" + limit).then(function (res) {
        if (res.data.code !== 500) {
          that.tableData = res.data.data;
          that.total = res.data.total;
          that.pageInfo.total = res.data.total;
          console.log(res.data)
        }else{
          console.log(res.data)
        }
      })
    }
    ,
    handleSizeChange(val) {
      this.pageInfo.pageSize = val;
      this.findList(this.pageInfo.pageNum, this.pageInfo.pageSize);
    },
    handleCurrentChange(val) {
      this.pageInfo.pageNum = val;
      this.findList(this.pageInfo.pageNum, this.pageInfo.pageSize);
    }
  }
}
</script>